<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./echarts.min.js"></script>
    <style>
      div {
        border: 1px solid #000;
      }
    </style>
  </head>
  <body>
    <div id="main" style="height: 600px; width: 800px"></div>
    <script>
      var myCharts = echarts.init(document.querySelector("#main"));
      const data = [
        {
          name: "Oranges",
          value: 40,
        },
        {
          name: "Pears",
          value: 32,
        },
        {
          name: "Pineapples",
          value: 27,
        },
        {
          name: "Grapes",
          value: 18,
        },
      ];
      const option = {
        title: [
          {
            text: "男女薪资分布",
          },
          {
            subtext: "男生",
            left: "50%",
            top: "40%",
            textAlign: "center",
          },
          {
            subtext: "女生",
            left: "50%",
            top: "75%",
            textAlign: "center",
          },
        ],
        series: [
          {
            type: "pie",
            radius: ["30%", "45%"],
            center: ["50%", "50%"],
            data: data,
            label: {
              position: "outer",
              alignTo: "none",
              bleedMargin: 5,
            },
            left: "33.3333%",
            right: "33.3333%",
            top: 0,
            bottom: 300,
          },
          {
            type: "pie",
            radius: ["30%", "45%"],
            center: ["50%", "50%"],
            data: data,
            label: {
              position: "outer",
              alignTo: "labelLine",
              bleedMargin: 5,
            },
            left: "33.3333%",
            right: "33.3333%",
            top: 150,
            bottom: 0,
          },
        ],
        color: ["#5dd499", "#f2a009", "#5fbdfc", "#6499ff"],
      };
      myCharts.setOption(option);
    </script>
  </body>
</html>
